export let initState = {
    list: [],
    n:null,
    id:3,
    name:'热门推荐',
    arr:[]
}

export const reducer = (state, action) => {
    switch(action.type){
        case "changeList":
            return {
                ...state,
                list:action.arr
            }
        case "changeN":
            return {
                ...state,
                n:action.num
            }
        case "changeId":
            return {
                ...state,
                id:action.id
            }
        case "changeName":
            return {
                ...state,
                name:action.name
            }
        case "changeArr":
            return {
                ...state,
                arr:action.arr
            }
        default:
            return state
    }
}
export let actions = {
    changeList:(arr)=>({type:"changeList",arr}),
    changeN:(num)=>({type:"changeN",num}),
    changeId:(id)=>({type:"changeId",id}),
    changeName:(name)=>({type:"changeName",name}),
    changeArr:(arr)=>({type:"changeArr",arr}),
}

export let getList = state => state.list
export let getN = state => state.n
export let getId = state => state.id
export let getName = state => state.name
export let getArr = state => state.arr